#import "ZQTabBar.h"
@interface ZQTabBar ()
@property (nonatomic, weak) UIButton *publishButton;
@property (nonatomic , weak) UIControl *previousClickedTabBarButton;
@end
@implementation ZQTabBar
- (UIButton *)publishButton
{
    if (_publishButton == nil) {
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
        [btn setImage:[UIImage imageNamed:@"tabBar_publish_icon"] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:@"tabBar_publish_click_icon"]  forState:UIControlStateHighlighted];
        [btn sizeToFit];
        [self addSubview:btn];
        _publishButton = btn;
    }
    return _publishButton;
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    self.backgroundColor = [UIColor whiteColor];
    NSInteger count = self.items.count;
    CGFloat btnW = self.zq_width / (count);
    CGFloat btnH = self.zq_height;
    CGFloat x = 0;
    int i = 0;
    for (UIControl *tabBarButton in self.subviews) {
        if ([tabBarButton isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
            tabBarButton.frame = CGRectMake(x, 0, btnW, btnH);
            if (i == 0  && self.previousClickedTabBarButton == nil) {
                self.previousClickedTabBarButton = tabBarButton;
            }
            x= i * btnW;
            tabBarButton.frame = CGRectMake(x, 0, btnW, btnH);
            i++;
        }
    }
}
- (void)tabBarClick:(UIControl *)tabBarButton
{
    if(self.previousClickedTabBarButton == tabBarButton)
    {
    }
    self.previousClickedTabBarButton = tabBarButton;
}
@end
